class Solution(object):
    def leftMostColumnWithOne(self, binaryMatrix):
        m, n = binaryMatrix.dimensions()
        min_col = n
        for i in range(m):
            left = 0
            right = n - 1
            while left <= right and left < min_col:
                mid = (left + right) // 2
                if binaryMatrix.get(i, mid):
                    right = mid - 1
                    min_col = min(min_col, mid)
                else:
                    left = mid + 1
        if min_col == n:
            return -1
        return min_col